package com.jcdd.object.front;


import lombok.AllArgsConstructor;
import lombok.Getter;


@AllArgsConstructor
@Getter
public class Result<T> {
    private Integer code; //响应状态码 1失败 0成功
    private String message; //提示信息
    private T data; //响应数据

    //操作成功 返回数据
    public static <E> Result<E> success(E data) {
        return new Result<>(0, "操作成功", data);
    }

    //操作成功 返回空
    public static Result success() {
        return new Result(0, "操作成功", null);
    }

    //操作失败
    public static Result error(String message) {
        return new Result(1, message, null);
    }

    public static Result error() {
        return new Result(1, "操作失败", null);
    }
}
